﻿using Dapper;
using GLstudent.Models;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace GLstudent.DAL
{
    public class DAL_zhuce
    {
        /// <summary>
        /// 查询教师表所有信息
        /// </summary>
        /// <returns></returns>
        public List<teacher> Select()
        {
            MySqlConnection mySqlConnection = new MySqlConnection(ConfigHelper.Configuration["MySQLConnectionString"]);
            var list = mySqlConnection.Query<teacher>("SELECT * FROM teacher ").ToList();
            return list;
        }
        /// <summary>
        /// 查询教师编号的方法
        /// </summary>
        /// <param name="t_bianhao">教师编号</param>
        /// <returns></returns>
        public teacher chaxunid(int t_bianhao)
        {
            MySqlConnection mySqlConnection = new MySqlConnection(ConfigHelper.Configuration["MySQLConnectionString"]);
            var chaxunid = mySqlConnection.QueryFirstOrDefault<teacher>("select *  from teacher where t_bianhao=@t_bianhao ", new { t_bianhao });
            return chaxunid;
        }
        /// <summary>
        /// 查询学生学号的方法
        /// </summary>
        /// <param name="s_xuehao">学生学号</param>
        /// <returns></returns>
        public zcstudent chaxunxs(int s_xuehao)
        {
            MySqlConnection mySqlConnection = new MySqlConnection(ConfigHelper.Configuration["MySQLConnectionString"]);
            var chaxunxs = mySqlConnection.QueryFirstOrDefault<zcstudent>("select *  from student where s_xuehao=@s_xuehao ", new { s_xuehao });
            return chaxunxs;
        }
    }
    }
